package com.moss.cloud.base.biz.controller;

import com.moss.cloud.base.api.model.from.BaseFrom;
import com.moss.cloud.base.api.model.from.FlowGroupFrom;
import com.moss.cloud.base.api.model.from.FlowGroupParam;
import com.moss.cloud.base.biz.service.IFlowGroupService;
import com.moss.cloud.common.core.constant.ServiceList;
import com.moss.cloud.common.core.model.Result;
import com.moss.cloud.common.security.annotation.SysLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 流程分组前端控制器
 *
 * @author 瑾年
 * @date 2024-02-04
 */
@RestController
@RequestMapping(ServiceList.BASE + "/flowGroup")
public class FlowGroupController {

    private final IFlowGroupService flowGroupService;

    public FlowGroupController(IFlowGroupService flowGroupService) {
        this.flowGroupService = flowGroupService;
    }

    /**
     * 分页查询
     *
     * @param param
     * @return
     */
    @PostMapping("/page")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "流程分组分页查询")
    public Result<?> page(@RequestBody @Validated FlowGroupParam param) {
        return Result.success(flowGroupService.page(param));
    }

    /**
     * 列表查询
     *
     * @param param
     * @return
     */
    @PostMapping("/list")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "流程分组列表查询")
    public Result<?> list(@RequestBody @Validated FlowGroupParam param) {
        return Result.success(flowGroupService.groupList(param));
    }

    /**
     * 新增
     *
     * @param from
     * @return
     */
    @PostMapping("/save")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "流程分组新增")
    public Result<?> save(@RequestBody @Validated FlowGroupFrom from) {
        return Result.success(flowGroupService.saveFlowGroup(from));
    }

    /**
     * 更新
     *
     * @param from
     * @return
     */
    @PostMapping("/update")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "流程分组更新")
    public Result<?> update(@RequestBody @Validated FlowGroupFrom from) {
        return Result.success(flowGroupService.update(from));
    }

    /**
     * 删除
     *
     * @param baseFrom
     * @return
     */
    @PostMapping("/remove")
    @SysLog(serverName = ServiceList.MOSS_CLOUD_BASE, operation = "流程分组删除")
    public Result<?> remove(@RequestBody @Validated BaseFrom baseFrom) {
        return Result.success(flowGroupService.remove(baseFrom));
    }


}
